package com.example.anno.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.util.StopWatch;

import java.text.MessageFormat;
import java.util.Arrays;
import java.util.stream.Collectors;

@Aspect
public class LogAspect {

    @Pointcut("execution(public * com.example.anno.aop.*.*(..))")
    public void pointCut() {}

    @Around("pointCut()")
    public Object around(ProceedingJoinPoint joinPoint) {
        Object returnValue ;
        try {
            // TODO aop testing
            String simpleName = joinPoint.getTarget().getClass().getSimpleName();
            String methodName = joinPoint.getSignature().getName();
            System.err.println(" -> [@Action]");
            returnValue = joinPoint.proceed();
        } catch (Throwable e) {
            throw new RuntimeException(e);
        }finally {
        }

        return returnValue;
    }
}
